<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >
                <p:growl />

                <p:panel header="Add Investigation to Package" >

                    <h:panelGrid columns="1" >
                        <h:selectOneListbox  id="lstSelect"   size="10" value="#{packageItemController.currentPackege}" style="min-width: 223px">
                            <f:selectItems  value="#{packageNameController.withoutInativeItems}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                            <f:ajax render="gpDetail" execute="lstSelect" >
                            </f:ajax>
                        </h:selectOneListbox>

                        <h:panelGroup>

                            <h:panelGrid columns="3" style="min-width: 100%;" >

                                <h:panelGroup id="gpDetail" >
                                    <h:selectOneListbox size="10" id="packageItem"  value="#{packageItemController.current}" >
                                        <f:selectItems value="#{packageItemController.items}" var="myPis"  itemLabel="#{myPis.item.name}" itemValue="#{myPis}"  />
                                    </h:selectOneListbox>
                                </h:panelGroup>

                                <h:panelGroup>
                                    <h:commandButton value="Add" action="#{packageItemController.addToPackage()}"></h:commandButton>
                                    <h:commandButton value="Remove" action="#{packageItemController.removeFromPackage()}"></h:commandButton>
                                </h:panelGroup>

                                <h:panelGroup >
                                    <p:dataTable value="#{packageItemController.serviceItems}" var="i" scrollable="true" rowKey="#{i.id}" scrollHeight="150" selectionMode="single" selection="#{packageItemController.currentItem}" filteredValue="#{packageItemController.filteredItems}">
                                        <p:column headerText="Department"  filterBy="#{i.department.name}" filterMatchMode="contains">
                                            #{i.department.name}
                                        </p:column> 
                                        <p:column headerText="Parent Category"  filterBy="#{i.category.parentCategory.name}" filterMatchMode="contains">
                                            #{i.category.parentCategory.name}
                                        </p:column> 
                                        <p:column headerText="Category"  filterBy="#{i.category.name}" filterMatchMode="contains">
                                            #{i.category.name}
                                        </p:column> 
                                         <p:column headerText="Item"  filterBy="#{i.name}" filterMatchMode="contains">
                                            #{i.name}
                                        </p:column> 
                                    </p:dataTable>
                                                                       
                                   
                                </h:panelGroup>

                            </h:panelGrid>


                        </h:panelGroup>

                    </h:panelGrid>

                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
